package monpkg.dao;
/**
 * @author Yannick Bouchot
 * @author Jonathan Romero
 */
import static org.junit.Assert.*;

import java.util.Date;
import java.util.List;

import monpkg.entities.Admin;
import monpkg.entities.Promotion;
import monpkg.entities.Student;
import monpkg.entities.Address;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

@SuppressWarnings("unused")
public class TestDao {

	static AnnuaireDAO annuaire;

	@BeforeClass
	public static void beforeAll() {
		annuaire = new Dao();
		annuaire.init();
	}

	@AfterClass
	public static void afterAll() {
		annuaire.close();
	}

	/**
	 * 
	 */
	@Before
	public void setUp() {
		// creation tables de la BDD
		Student S = new Student();
		Admin A = new Admin();
		Promotion P = new Promotion();
	}

	@After
	public void tearDown() {

	}

	@Test
	public void testAddStudent() {
		Student S = new Student("NOM1", "PRENOM1", "mail@serv.com", "1234");
		annuaire.addStudent(S);
	}

	// @Test
	public void testFindStudent() {
		annuaire.findStudent(1);
	}

	@Test
	public void testFindAllStudents() {
		annuaire.findAllStudents();
	}
	
	// @Test
	public void testRemoveStudent() {
		annuaire.removeStudent(1);
	}
	
	@Test
	public void testAddAdmin() {
		Admin A = new Admin("NOM_ADMIN_1", "PRENOM_ADMIN_1", "mail_admin@serv.com", "1234");
		annuaire.addAdmin(A);
	}

	@Test
	public void testFindAdmin() {
		annuaire.findAdmin(1);
	}
	
	@Test
	public void testUpdateAdmin() {
		Admin A = annuaire.findAdmin(1);
		A.setFirstName("NewName");
		annuaire.updateAdmin(A);
	}
	

	@Test
	public void testAddPromotion() {
		Promotion p = new Promotion("Promotion Test", "codePromo",
				"une petite description", "2011 - 2012");

		annuaire.addPromotion(p);
	}

	@Test
	public void testFindPromotion() {
		annuaire.findPromotion(1, true);
	}

	//@Test
	public void testFindAllPromotions() {
		annuaire.findAllPromotions();
	}
	
	//@Test
	public void testUpdatePromotion() {
		Promotion p = annuaire.findPromotion(1, true);
		String s = "description ici !";
		p.setDescription(s);		
		annuaire.updatePromotion(p);
	}

	//@Test
	public void testRemovePromotion() {
		annuaire.removePromotion(1);
		System.out.println("yataa");
	}
}